package com.imooc.town.controller;

import com.imooc.town.dto.OrderDTO;
import com.imooc.town.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * create by song on 2018/3/25
 * To change this template use File | Settings | File Templates.
 */

@RequestMapping("")
@Controller
public class SellerOrderController {

    @Autowired
    private OrderService orderService;


    public ModelAndView list(@RequestParam(value = "page" ,defaultValue = "1") Integer page,
                             @RequestParam(value = "size",defaultValue = "10") Integer size,
                                     Map<String,Object> map){
        PageRequest pageRequest = new PageRequest ( page-1,size );
        Page<OrderDTO> orderDTOPage = orderService.list ( pageRequest );
        map.put ( "orderDTOPage",orderDTOPage );
        return new ModelAndView ( "order/list",map );
    }
}
